* ----------------------------------------------------------------------------- *
* Natural Resource Rents, Local Taxes, and Government Performance: Evidence from
* Colombia
* By: Luis R. Martinez
* Name: 		00-master.do
* Description:  This do file runs all the codes necessary to replicate the figures and tables of the paper. 
* ----------------------------------------------------------------------------- *

/* 
Note: Before running this do-file, 

		1. you must manually set a directory with the following structure:
		./data/: 	 Data folder containing "raw" subfolder. 	
		./data/raw/: folder with 16 subfolders containing raw data.
		./code:		 folder with provided do-files.
		
		2. you must adjust the global "root" in line 36 to match the path containing the folders above
		
		3. you must set the global "install_programs" in line 72 equal to one if you want to install the additional necessary commands
*/	

* ----------------------------------------------------------------------------- *
* Settings																		*
* ----------------------------------------------------------------------------- *

cls
clear 				all 
set more 			off 
set graphics 		on 
version 			17   /* Use Stata 17 */ 
macro drop _all

* ----------------------------------------------------------------------------- *
* Directory 																	*
* ----------------------------------------------------------------------------- *

* Please set here your local path to the folder:
global root "XXX"

cd "$root"

* Data Directories:
global dpraw "${root}\data\raw"
global dpwork "${root}\data\work"
global dptemp "${root}\data\temp"

* Results Directories
global dpmain "${root}\results\main"
global dpappendix "${root}\results\appendix"


* ----------------------------------------------------------------------------- *
* Folder Set Up: 																*
* ----------------------------------------------------------------------------- *

* This code will create all aditional folders required for the analysis:	

cap mkdir "${root}\data\work"
cap mkdir "${root}\data\temp"
cap mkdir "${root}\results"
cap mkdir "${root}\results\main"
cap mkdir "${root}\results\appendix"
cap mkdir "${root}\results\appendix\A-data"
cap mkdir "${root}\results\appendix\B-additional"
cap mkdir "${root}\results\appendix\C-cadastral-tests"
cap mkdir "${root}\results\appendix\D-robustness"

* ----------------------------------------------------------------------------- *
* Programs 																		*
* ----------------------------------------------------------------------------- *

global install_programs = 0 	/* Install stata programs */


*) Install stata programs
if ${install_programs} == 1 {
cap ssc install outreg2
cap ssc install reghdfe
cap ssc install ivreghdfe
cap ssc install ftools
cap ssc install ivreg2
cap ssc install splitvallabels
cap ssc install parmest
}

* ----------------------------------------------------------------------------- *
* Data Cleaning																	*
* ----------------------------------------------------------------------------- *

do "${root}/code/10-panel-set-up"

do "${root}/code/11-final-panel"

* ----------------------------------------------------------------------------- *
* Tables and Figures															*
* ----------------------------------------------------------------------------- *

do "${root}/code/20-estimation.do"

do "${root}/code/30-appendix.do"
